Dynomotion

Group: DynoMotion Message: 5666 From: amitgoradia Date: 9/14/2012
Subject: Calling KMotionDLL from a python program
Hi

New user for KFLOP card.

I want to call KmotionDLL and GcodeinterpreterDLL from a python program.
Python 2.7.

Is there an easy way to do this? Has someone done this before? Can someone point me int he right direction to get this going?

For python I would like to use Ctypes but any other method like CPython or Boost::Python is also OK.

Regards,

Amit Goradia
Group: DynoMotion Message: 5667 From: brad murry Date: 9/14/2012
Subject: Re: Calling KMotionDLL from a python program
I know in Linux there are many programs where c++objects are called from python, but I'm not sure how you would do it in windows.

The super easy route would be to install Iron Python and import the .net all.  All objects would become immediately  available.

-Brad Murry

From: amitgoradia
Sent: 9/14/2012 12:15 AM
To: DynoMotion@yahoogroups.com
Subject: [DynoMotion] Calling KMotionDLL from a python program

 

Hi

New user for KFLOP card.

I want to call KmotionDLL and GcodeinterpreterDLL from a python program.
Python 2.7.

Is there an easy way to do this? Has someone done this before? Can someone point me int he right direction to get this going?

For python I would like to use Ctypes but any other method like CPython or Boost::Python is also OK.

Regards,

Amit Goradia

Group: DynoMotion Message: 5672 From: Amit Goradia Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
HiBrad,

I have tried doing this using the KMViaVB.dll and have had some success using it from Python using Ctypes.

Following is working code:
#**************************************
# filename: calldll.py
# Make sure to include the Kmotion.dll and KMViaVB.dll in the same folder as this python file or that it is somewhere in your windows #path
#*************************************
import ctypes
import _ctypes;
# give location of dll
amitdll = ctypes.WinDLL("KMViaVB.dll")

hdl = ctypes.c_long(10)
print hdl

result = amitdll.KMViaVB_Test1()
print result
result = amitdll.KMViaVB_Test2(hdl)
print result

hdl.value = hdl.value +10
result = amitdll.KMViaVB_Test3(ctypes.byref(hdl))
print result

result = amitdll.KMViaVB_New(ctypes.byref(hdl))
print "km new" , result

result = amitdll.KMViaVB_WriteLine(hdl, "MoveRel0=100")
print "km move" , result

result = amitdll.KMViaVB_Free(ctypes.byref(hdl))
print "km_free", result
#*******************

run this using:
python calldll.py


This results in motion.

Now I will try using the coordinated motion library. Is there any thing like KMViaVB.dll for GcodeInterpreter.dll? Or will I have to make it?

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Fri, Sep 14, 2012 at 6:43 PM, brad murry <bradodarb@...> wrote:
 

I know in Linux there are many programs where c++objects are called from python, but I'm not sure how you would do it in windows.

The super easy route would be to install Iron Python and import the .net all.  All objects would become immediately  available.

-Brad Murry

From: amitgoradia
Sent: 9/14/2012 12:15 AM
To: DynoMotion@yahoogroups.com
Subject: [DynoMotion] Calling KMotionDLL from a python program


 

Hi

New user for KFLOP card.

I want to call KmotionDLL and GcodeinterpreterDLL from a python program.
Python 2.7.

Is there an easy way to do this? Has someone done this before? Can someone point me int he right direction to get this going?

For python I would like to use Ctypes but any other method like CPython or Boost::Python is also OK.

Regards,

Amit Goradia


Group: DynoMotion Message: 5673 From: brad murry Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
Hello,

-Brad Murry

From: Amit Goradia
Sent: 9/15/2012 12:35 AM
To: DynoMotion@yahoogroups.com
Subject: Re: [DynoMotion] Calling KMotionDLL from a python program

 

HiBrad,


I have tried doing this using the KMViaVB.dll and have had some success using it from Python using Ctypes.

Following is working code:
#**************************************
# filename: calldll.py
# Make sure to include the Kmotion.dll and KMViaVB.dll in the same folder as this python file or that it is somewhere in your windows #path
#*************************************
import ctypes
import _ctypes;
# give location of dll
amitdll = ctypes.WinDLL("KMViaVB.dll")

hdl = ctypes.c_long(10)
print hdl

result = amitdll.KMViaVB_Test1()
print result
result = amitdll.KMViaVB_Test2(hdl)
print result

hdl.value = hdl.value +10
result = amitdll.KMViaVB_Test3(ctypes.byref(hdl))
print result

result = amitdll.KMViaVB_New(ctypes.byref(hdl))
print "km new" , result

result = amitdll.KMViaVB_WriteLine(hdl, "MoveRel0=100")
print "km move" , result

result = amitdll.KMViaVB_Free(ctypes.byref(hdl))
print "km_free", result
#*******************

run this using:
python calldll.py


This results in motion.

Now I will try using the coordinated motion library. Is there any thing like KMViaVB.dll for GcodeInterpreter.dll? Or will I have to make it?

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Fri, Sep 14, 2012 at 6:43 PM, brad murry <bradodarb@...> wrote:
 

I know in Linux there are many programs where c++objects are called from python, but I'm not sure how you would do it in windows.

The super easy route would be to install Iron Python and import the .net all.  All objects would become immediately  available.

-Brad Murry

From: amitgoradia
Sent: 9/14/2012 12:15 AM
To: DynoMotion@yahoogroups.com
Subject: [DynoMotion] Calling KMotionDLL from a python program


 

Hi

New user for KFLOP card.

I want to call KmotionDLL and GcodeinterpreterDLL from a python program.
Python 2.7.

Is there an easy way to do this? Has someone done this before? Can someone point me int he right direction to get this going?

For python I would like to use Ctypes but any other method like CPython or Boost::Python is also OK.

Regards,

Amit Goradia


Group: DynoMotion Message: 5674 From: brad murry Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
Hello,

The quickest path to success and access to the entire API is by using Iron Python (keep in mind you can still run straight python from it).

Do you have reservations against using Iron Python?

At any rate, if you absolutely must use straight python then you can use a version of the .net Dll Shannon compiled that exports the types.

Search this forum for .net dll with vb6.

-Brad Murry

From: Amit Goradia
Sent: 9/15/2012 12:35 AM
To: DynoMotion@yahoogroups.com
Subject: Re: [DynoMotion] Calling KMotionDLL from a python program

 

HiBrad,


I have tried doing this using the KMViaVB.dll and have had some success using it from Python using Ctypes.

Following is working code:
#**************************************
# filename: calldll.py
# Make sure to include the Kmotion.dll and KMViaVB.dll in the same folder as this python file or that it is somewhere in your windows #path
#*************************************
import ctypes
import _ctypes;
# give location of dll
amitdll = ctypes.WinDLL("KMViaVB.dll")

hdl = ctypes.c_long(10)
print hdl

result = amitdll.KMViaVB_Test1()
print result
result = amitdll.KMViaVB_Test2(hdl)
print result

hdl.value = hdl.value +10
result = amitdll.KMViaVB_Test3(ctypes.byref(hdl))
print result

result = amitdll.KMViaVB_New(ctypes.byref(hdl))
print "km new" , result

result = amitdll.KMViaVB_WriteLine(hdl, "MoveRel0=100")
print "km move" , result

result = amitdll.KMViaVB_Free(ctypes.byref(hdl))
print "km_free", result
#*******************

run this using:
python calldll.py


This results in motion.

Now I will try using the coordinated motion library. Is there any thing like KMViaVB.dll for GcodeInterpreter.dll? Or will I have to make it?

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Fri, Sep 14, 2012 at 6:43 PM, brad murry <bradodarb@...> wrote:
 

I know in Linux there are many programs where c++objects are called from python, but I'm not sure how you would do it in windows.

The super easy route would be to install Iron Python and import the .net all.  All objects would become immediately  available.

-Brad Murry

From: amitgoradia
Sent: 9/14/2012 12:15 AM
To: DynoMotion@yahoogroups.com
Subject: [DynoMotion] Calling KMotionDLL from a python program


 

Hi

New user for KFLOP card.

I want to call KmotionDLL and GcodeinterpreterDLL from a python program.
Python 2.7.

Is there an easy way to do this? Has someone done this before? Can someone point me int he right direction to get this going?

For python I would like to use Ctypes but any other method like CPython or Boost::Python is also OK.

Regards,

Amit Goradia


Group: DynoMotion Message: 5676 From: Amit Goradia Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
Hi Brad,

The reason I want to use Cpython is the GUI Toolkit I am using. I use wxPython for my GUI and I am heavily invested in it. WxPython does not work out of the box for Iron Python. So using Iron Python would heavily fragment my current codebase. 

I am trying to make a changable backend for a motion control GUI. So working with Cpython is a must.

I also got some of the functions from CoordMotion working with the DLL and CPython today.

However, I like your idea of the VB DLL and will look for it. I dont fancy the idea of manually writing wrappers for all the class functions in GCodeInterpreter.dll.

I will post back my results on the VB DLL as soon as I get it to work.

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sat, Sep 15, 2012 at 7:41 PM, brad murry <bradodarb@...> wrote:
.net dll with vb6

Group: DynoMotion Message: 5679 From: Amit Goradia Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
Hi Brad,

Just looked at Kmotion_dotnet_Interop project. It has the complete API Exported as "C" functions which take input as a handle to an object of type Kmotion 
Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sat, Sep 15, 2012 at 11:49 PM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

The reason I want to use Cpython is the GUI Toolkit I am using. I use wxPython for my GUI and I am heavily invested in it. WxPython does not work out of the box for Iron Python. So using Iron Python would heavily fragment my current codebase. 

I am trying to make a changable backend for a motion control GUI. So working with Cpython is a must.

I also got some of the functions from CoordMotion working with the DLL and CPython today.

However, I like your idea of the VB DLL and will look for it. I dont fancy the idea of manually writing wrappers for all the class functions in GCodeInterpreter.dll.

I will post back my results on the VB DLL as soon as I get it to work.

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sat, Sep 15, 2012 at 7:41 PM, brad murry <bradodarb@...> wrote:
.net dll with vb6


Group: DynoMotion Message: 5680 From: Amit Goradia Date: 9/15/2012
Subject: Re: Calling KMotionDLL from a python program
Hi Brad,

Just looked at Kmotion_dotnet_Interop project. It has the complete API Exported as "C" functions which take input as a handle to an object of type Kmotion or CoordMotion.

This is exactly what I had started to implement I got the first few functions (Straightteaverse, straightfeed and arcfeed done). 

Just never thought of looking at the Kmotion_dotnet_interop project as I figured it would be all managed code stuff for .net. Using the KMotion_dotnet_Interop project and changing the compile settings for the project will get me to my destination much faster.

Thanks, I will try to post my project working with python in the near future for prospective users of Kmotion...

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sun, Sep 16, 2012 at 12:10 AM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

 

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sat, Sep 15, 2012 at 11:49 PM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

The reason I want to use Cpython is the GUI Toolkit I am using. I use wxPython for my GUI and I am heavily invested in it. WxPython does not work out of the box for Iron Python. So using Iron Python would heavily fragment my current codebase. 

I am trying to make a changable backend for a motion control GUI. So working with Cpython is a must.

I also got some of the functions from CoordMotion working with the DLL and CPython today.

However, I like your idea of the VB DLL and will look for it. I dont fancy the idea of manually writing wrappers for all the class functions in GCodeInterpreter.dll.

I will post back my results on the VB DLL as soon as I get it to work.

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sat, Sep 15, 2012 at 7:41 PM, brad murry <bradodarb@...> wrote:
.net dll with vb6



Group: DynoMotion Message: 5694 From: Amit Goradia Date: 9/20/2012
Subject: Re: Calling KMotionDLL from a python program
hi Brad and Tom,

I converted a part of  GcodeInterpreter.dll for use with Cpython. I am able to use the callback mechanism as well as passing structure pointers to the Kmotion.dll and GcodeInterpreter.dll. Using the dll I made I can control the KFLOP board by moving motors etc. I would like to post this "Extension" DLL project somewhere for all KMotion users. Can you suggest how to do that.

For further development for a python application using this extension dll, I have a very myopic view of the functions in GcodeInterpreter.dll that I have exposed. I am poring over the code of KMotionCNC application but am having a tough time trying to put all the pieces together. Do you have some reading material that might make this job a little easier?

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sun, Sep 16, 2012 at 12:16 AM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

Just looked at Kmotion_dotnet_Interop project. It has the complete API Exported as "C" functions which take input as a handle to an object of type Kmotion or CoordMotion.

This is exactly what I had started to implement I got the first few functions (Straightteaverse, straightfeed and arcfeed done). 

Just never thought of looking at the Kmotion_dotnet_interop project as I figured it would be all managed code stuff for .net. Using the KMotion_dotnet_Interop project and changing the compile settings for the project will get me to my destination much faster.

Thanks, I will try to post my project working with python in the near future for prospective users of Kmotion...

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sun, Sep 16, 2012 at 12:10 AM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

 

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sat, Sep 15, 2012 at 11:49 PM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

The reason I want to use Cpython is the GUI Toolkit I am using. I use wxPython for my GUI and I am heavily invested in it. WxPython does not work out of the box for Iron Python. So using Iron Python would heavily fragment my current codebase. 

I am trying to make a changable backend for a motion control GUI. So working with Cpython is a must.

I also got some of the functions from CoordMotion working with the DLL and CPython today.

However, I like your idea of the VB DLL and will look for it. I dont fancy the idea of manually writing wrappers for all the class functions in GCodeInterpreter.dll.

I will post back my results on the VB DLL as soon as I get it to work.

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sat, Sep 15, 2012 at 7:41 PM, brad murry <bradodarb@...> wrote:
.net dll with vb6




Group: DynoMotion Message: 5695 From: Tom Kerekes Date: 9/21/2012
Subject: Re: Calling KMotionDLL from a python program
Hi Amit,
 
Please make a Python folder in the Files Section of this group and post the files there.  Thanks!
 
 
We don't really have any write up on the internal workings of the KMotionCNC application.  It is pretty much a standard MFC GUI application.  Of course the decription of what it does is here: http://www.dynomotion.com/Help/KMotionCNC/KMotionCNC.htm 
I'd be happy to answer any specific questions.
Regards
TK

Group: DynoMotion Message: 5697 From: brad murry Date: 9/22/2012
Subject: Re: Calling KMotionDLL from a python program
Amit,

That is good news, I have always believed that actual machine/robot behavior is best served by a dynamic scripting language.

I thought you were able to hook into the interop dll for this.  It would be nice to have a common export point, but I'm sure you had a good reason for creating a new export library.  As I have never exposed c++calls directly to python, I would be quite interested to hear why you created your own exports rather than use the existing one that already exposes 99% of the functionality.


Sounds pretty cool, I will play with it once it is available.  Can you provide a readme that explains the python version required and maybe even outline the object calls?

Good job!

-Brad Murry

From: Amit Goradia
Sent: 9/20/2012 11:01 PM
To: DynoMotion@yahoogroups.com
Subject: Re: [DynoMotion] Calling KMotionDLL from a python program

 

hi Brad and Tom,


I converted a part of  GcodeInterpreter.dll for use with Cpython. I am able to use the callback mechanism as well as passing structure pointers to the Kmotion.dll and GcodeInterpreter.dll. Using the dll I made I can control the KFLOP board by moving motors etc. I would like to post this "Extension" DLL project somewhere for all KMotion users. Can you suggest how to do that.

For further development for a python application using this extension dll, I have a very myopic view of the functions in GcodeInterpreter.dll that I have exposed. I am poring over the code of KMotionCNC application but am having a tough time trying to put all the pieces together. Do you have some reading material that might make this job a little easier?

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sun, Sep 16, 2012 at 12:16 AM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

Just looked at Kmotion_dotnet_Interop project. It has the complete API Exported as "C" functions which take input as a handle to an object of type Kmotion or CoordMotion.

This is exactly what I had started to implement I got the first few functions (Straightteaverse, straightfeed and arcfeed done). 

Just never thought of looking at the Kmotion_dotnet_interop project as I figured it would be all managed code stuff for .net. Using the KMotion_dotnet_Interop project and changing the compile settings for the project will get me to my destination much faster.

Thanks, I will try to post my project working with python in the near future for prospective users of Kmotion...

Regards,

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sun, Sep 16, 2012 at 12:10 AM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

 

Amit Goradia, Ph.D.,
Automata Systems,
141 Veena Dalvai Indst. Est.,
S. V. Road, Jogeshwari (W),
Mumbai 400102. India.
Ph: +91 97696 84015


On Sat, Sep 15, 2012 at 11:49 PM, Amit Goradia <amitgoradia@...> wrote:
Hi Brad,

The reason I want to use Cpython is the GUI Toolkit I am using. I use wxPython for my GUI and I am heavily invested in it. WxPython does not work out of the box for Iron Python. So using Iron Python would heavily fragment my current codebase. 

I am trying to make a changable backend for a motion control GUI. So working with Cpython is a must.

I also got some of the functions from CoordMotion working with the DLL and CPython today.

However, I like your idea of the VB DLL and will look for it. I dont fancy the idea of manually writing wrappers for all the class functions in GCodeInterpreter.dll.

I will post back my results on the VB DLL as soon as I get it to work.

Regards,

Amit Goradia, Ph.D.,
Automata Systems,


On Sat, Sep 15, 2012 at 7:41 PM, brad murry <bradodarb@...> wrote:
.net dll with vb6